package com.kgc.scd.service.impl;

import com.kgc.scd.bean.CouponUserInner;
import com.kgc.scd.bean.CouponUserInnerExample;
import com.kgc.scd.bean.NotifyProArrive;
import com.kgc.scd.bean.NotifyProArriveExample;
import com.kgc.scd.mapper.CouponUserInnerMapper;
import com.kgc.scd.mapper.NotifyProArriveMapper;
import com.kgc.scd.service.CouponUserInnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created On : 2022/6/15.
 * <p>
 * Author     : nainai
 * <p>
 * Description: 用户优惠券关联业务实现类
 */
@Service
public class CouponUserInnerServiceImpl implements CouponUserInnerService {

    @Autowired(required = false)
    private CouponUserInnerMapper couponUserInnerMapper;

    @Autowired(required = false)
    private NotifyProArriveMapper notifyProArriveMapper;

    @Override
    public List<CouponUserInner> getCouponUserInnerByCouIdAndUserId(String userId, Integer couId) {
        CouponUserInnerExample couponUserInnerExample = new CouponUserInnerExample();
        CouponUserInnerExample.Criteria criteria = couponUserInnerExample.createCriteria();

        criteria.andUserIdEqualTo(userId).andCouIdEqualTo(couId);
        return couponUserInnerMapper.selectByExample(couponUserInnerExample);
    }

    @Override
    public CouponUserInner getCouponUserInnerByInnerId(Integer innerId) {
        return couponUserInnerMapper.selectByPrimaryKey(innerId);
    }

    @Override
    public List<NotifyProArrive> getCouponUserInnerByProId(String proId) {
        NotifyProArriveExample notifyProArriveExample = new NotifyProArriveExample();
        NotifyProArriveExample.Criteria criteria = notifyProArriveExample.createCriteria();

        criteria.andProIdEqualTo(proId).andStatusEqualTo(0);
        return notifyProArriveMapper.selectByExample(notifyProArriveExample);
    }
}
